@ layout("/common/_curd/_container.html"){
<script type="text/javascript">
    var ctx="${basePath}";
    var grid_selector = "#grid-table";
    var pager_selector = "#grid-pager";

    $(function(){
        initGrid();
        // initMenuBtn("btns","${code}");
		$("#itemmanage_wnxm").click(function () {
            var row;
            //选择行数据检验
            row = selectCheck();

            if (row == undefined){
                return;
            }

            layer.confirm('确认本此操作吗？', {
                btn: ['确定', '取消'], //可以无限个按钮
                btn1: function(index, layero){
                    $.get(ctx+"/${code}/update",{xmid:row.id,itemtype:1},function (data,status,xhr) {
                        refresh();
                    });
                }
            });
        });

        $("#itemmanage_qqxm").click(function () {
            var row;
            row = selectCheck();
            if (row == undefined){
                return;
            }

            layer.confirm('确认本此操作吗？', {
                btn: ['确定', '取消'], //可以无限个按钮
                btn1: function(index, layero){
                    $.get(ctx+"/${code}/update",{xmid:row.id,itemtype:2},function (data,status,xhr) {
                        refresh();
                    });
                }
            });
        });

        $("#itemmanage_bndxm").click(function () {
            var row;
            row = selectCheck();
            if (row == undefined){
                return;
            }
            layer.confirm('确认本此操作吗？', {
                btn: ['确定', '取消'], //可以无限个按钮
                btn1: function(index, layero){
                    $.get(ctx+"/${code}/update",{xmid:row.id,itemtype:3},function (data,status,xhr) {
                        refresh();
                    });
                }
            });
        });
    });

    function refresh() {
        $(grid_selector).jqGrid().trigger('reloadGrid');
        layer.msg("操作成功")
    }
    
    function selectCheck() {
        var selarrrow = $(grid_selector).jqGrid('getGridParam','selarrrow');
        if (selarrrow.length == 0){
            layer.msg("请选择一行进行操作！");
            return;
        }

        if (selarrrow.length > 1){
            layer.msg("请选择一行进行操作！");
            return;
        }else{
            
            return $(grid_selector).jqGrid('getRowData',selarrrow);
        }
    }

    function initGrid(){
        var grid_url = ctx+"/${code}/list";//查询列表接口
        var _colnames=[ "主键","项目名称",
            "申报单位",
            "责任单位",
            "建设起止年限",
            "建设结束时间",
            "状态"];
        var _colmodel=[
            {name:"id", index:"id", hidden:true,width:100},
            {name:"name", index:"name", width:100,formatter:function (cellvalue, options, rowObject) {
                    return '<a href="#" class="btn btn-btn btn-info btn-xs" onclick="view('+"'"+rowObject.id+"'"+')">'+cellvalue+'</a>';
                }},
            {name:"fullname", index:"fullname", width:100},
            {name:"responsible", index:"responsible", width:100},
            {name:"start", index:"start", width:100 ,formatter:function (value, row, index) {
                    var over = index.over;
                    var start = value;
                    if(start !== null && over!==null){
                        return start.substr(0,7)+" 至 "+over.substr(0,7);
                    }else{
                        return "未录入";
                    }

                }},
            {name:"over", index:"over", width:100},
            {name:"status", width:100,formatter:function (value,row,index) {
				return "竣工验收通过";

            }}
        ];

        jQuery(grid_selector).jqGrid({
            url:grid_url,
            shrinkToFit:true,//适用于较少字段,响应式
            colNames:_colnames,
            colModel:_colmodel,
            jsonReader:{id:"F_IT_XL"},
            pager : pager_selector,
            ondblClickRow : page_add,
            postData: {sort: "F_IT_XL", order: "desc"}
        });


    }

    function page_add(){
        $("${code}_add").click();
    }

    function view(pid){
        var index = layer.open({
            type: 2,
            title:'查看详情',
            area: ['90%', '70%'],
            maxmin:true,
            shadeClose: true, //点击遮罩关闭

            content:  ctx+'/projects/view?id=' + pid
        });

        this.layerIndex = index;
    }

</script>


<!-- 配置grid -->
<div class="row">
	<div class="col-xs-12 tb-grid">
		<!-- 按钮组 -->
		<!--<div class="welljq well-sm" id="btns"></div>-->
		<!--<div class="welljq well-sm" id="btns">-->
			<!--<button class="btn btn-xs btn-white " id="itemmanage_wnxm">&nbsp;<li class=" fa fa-folder-o bigger-120"></li>&nbsp;往年项目&nbsp;</button>&nbsp;<button class="btn btn-xs btn-white " id="itemmanage_qqxm">&nbsp;<li class=" fa fa-folder-o  bigger-120"></li>&nbsp;前期项目&nbsp;</button>&nbsp;<button class="btn btn-xs btn-white " id="itemmanage_bndxm">&nbsp;<li class=" fa fa-folder-o  bigger-120"></li>&nbsp;本年度项目&nbsp;</button>&nbsp;</div>-->
		<!-- grid -->
		<table id="grid-table"></table>
		<!-- 分页 -->
		<div id="grid-pager"></div>

	</div>
</div>

<!-- 引入列表页所需js -->
@include("/common/_listscript.html"){}
@}